<!--START JS-->
<i id="scriptTag">/static/js/console/couponEdit.js</i>
<link href="/static/css/plugins/footable/footable.core.css" rel="stylesheet">
<link href="/static/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<link href="/static/css/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet">
<!--END JS-->

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2><?php echo $page_title; ?></h2>
        <p>您可在此进行<?php echo $page_title; ?></p>
    </div>
    <div class="col-lg-2"></div>
</div>

<!--START coupon-->
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5><?php echo $page_title; ?></h5>
                </div>
                <div class="ibox-content">
                    <div id="coupon-add-list" class="tab-pane">
                        <div class="panel-body">
                            <div class="form-group">
                                <label>选择门店：</label>
                                <select class="form-control" id="shop-chosen">
                                    <?php foreach ($shop as $item) { ?>
                                        <option 
                                            value="<?php echo $item['id']; ?>"
                                            data-phone="<?php echo $item['shop_phone']; ?>"
                                            data-address="<?php echo $item['shop_province'] . ' ' . $item['shop_city'] . ' ' . $item['shop_address']; ?>"
                                            <?php if ($item['id'] === $coupon['shop_id']) echo 'selected'; ?>
                                            >
                                                <?php echo $item['shop_name']; ?>
                                        </option>
                                    <?php } ?>
                                </select>
                            </div>
                            <input type="hidden" value="<?php echo $coupon['id'];?>" id="coupon-id">
                            <div class="form-group" id="branche-chosen">
                                <label>选择分店：</label>
                                <p id="branche-empty" class="text-navy" style="display: none;">该门店没有分店,默认使用门店地址</p>
                                <select id="branche-not-empty" class="form-control" style="display: none;"></select>
                                <script type="text/x-jquery-tmpl" id="branche-chosen-tmpl">
                                    <option value="{{= id}}" 
                                    data-phone="{{= branche_phone}}" data-address="{{= branche_province}} {{= branche_city}} {{= branche_address}}">
                                    {{= branche_name}}
                                    </option>
                                </script>
                            </div>
                            <input type="hidden" value="<?php echo $coupon['branche_id']; ?>" id="branche-id">
                            <div class="form-group" >
                                <label>地址明细：</label>
                                <p id="address-detail"></p>
                            </div>
                            <div class="form-group">
                                <label>优惠信息：</label>
                                <input type="text" class="form-control" placeholder="请填写优惠信息" id="coupon-info" value="<?php echo $coupon['coupon_info']; ?>">
                            </div>
                            <div class="form-group">
                                <label>使用规则：</label>
                                <textarea id="coupon-rule" class="form-control" style="min-height:150px;" placeholder="请填写使用规则" ><?php echo $coupon['coupon_rule']; ?></textarea>
                            </div>
                            <div class="form-group">
                                <label>发放数量：</label>
                                <input id="coupon-count" type="number" class="form-control" placeholder="请填写发放数量" value="<?php echo $coupon['coupon_count']; ?>">
                            </div>
                            <div class="form-group">
                                <label>有效期：</label>
                                <div class="input-daterange input-group" id="datepicker">
                                    <input type="text" class="input-sm form-control" value="<?php echo date('Y-m-d', $coupon['coupon_start']); ?>" id="coupon-start">
                                    <span class="input-group-addon">至</span>
                                    <input type="text" class="input-sm form-control" value="<?php echo date('Y-m-d', $coupon['coupon_end']); ?>" id="coupon-end">
                                </div>
                            </div>
                            <div class="form-group">
                                <button id="save-btn" class="btn btn-primary">保存</button>
                            </div>
                        </div>
                    </div>		

                </div>
            </div>
        </div>
    </div>
</div>
<!--END coupon-->